
#include <LengthUnit.h>


const int __BASE_UNIT__ = 1;

const int INCH_TO_BASE = __BASE_UNIT__;
const int FEET_TO_BASE = 12 * INCH_TO_BASE;
const int YARD_TO_BASE = 3 * FEET_TO_BASE;
const int MILE_TO_BASE = 1760 * YARD_TO_BASE;

LengthUnit::LengthUnit(int factorToBase, string name):Unit(factorToBase),name_m(name)
{
}
string LengthUnit::formate(const int value) const
{
	ostringstream os;

	if (value != 0) {
		os << value <<" "<< name_m;
	}

	return os.str();
}
LengthUnit& LengthUnit::getBaseUnit()
{
	static LengthUnit theBase(__BASE_UNIT__, "INCH");
	
	return theBase;
}
LengthUnit& LengthUnit::getInchUnit()
{
	static LengthUnit theInch(INCH_TO_BASE, "INCH");
	
	return theInch;
}
LengthUnit& LengthUnit::getFeetUnit()
{
	static LengthUnit theFeet(FEET_TO_BASE, "FEET");
	
	return theFeet;
}
LengthUnit& LengthUnit::getYardUnit()
{
	static LengthUnit theYard(YARD_TO_BASE, "YARD");
	
	return theYard;
}
LengthUnit& LengthUnit::getMileUnit()
{
	static LengthUnit theMile(MILE_TO_BASE, "MILE");
	
	return theMile;
}

